package com.lvmama.rhino.job;

import com.lvmama.rhino.service.NPSService;
import com.lvmama.rhino.utils.Constants;
import com.lvmama.rhino.utils.RhinoConstant;
import org.apache.log4j.Logger;
import org.quartz.JobExecutionContext;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author caoyong
 * @version 1.0.0
 * @since 2017-12-18 15:21
 **/
public class NPSPushEmailJob extends BaseQuartzJobBean {
    public static Logger log = Logger.getLogger(NPSPushEmailJob.class);
    @Autowired
    private NPSService npsService;

    @Override
    public void invoke(JobExecutionContext context) {
        log.info("invoke NPSPushEmailJob start.");
        try {
            //只有生产才发
            RhinoConstant rhinoConstant = RhinoConstant.getInstance();
            String env = rhinoConstant.getValue("rhino.env");
            if(!Constants.EVN_PRD.equals(env)){
                return;
            }
            boolean flag = npsService.sendNPSEmail();
            log.info("sendNPSEmail is:" + flag);
        } catch (Exception e) {
            log.error("invoke NPSPushEmailJob error:" + e.getMessage(), e);
        }

        log.info("invoke NPSPushEmailJob end.");
    }


}
